package com.xz.knowledgeDuplication.pattern.expression;

/**
 * 变量(终结符表达式角色)
 *
 * @author 召
 * @date 2022-04-04 22:09:00
 */
public class Variable extends AbstractExpression{

    /**
     * 变量名
     */
    private String name;

    public Variable(String name) {
        this.name = name;
    }

    @Override
    public int interpret(ExpressionContext context) {
        return context.getValue(this);
    }

    @Override
    public String toString() {
        return this.name;
    }
}
